<template>
  <div class="schoolDetail">
    <goBack :title="info.titile"></goBack>
    <div v-if="type != 'zs'" class="schools-nav">
      <div
        :style="{ background: tabIndex == 0 ? '#e9efff' : '' }"
        class="schools-nav-left"
        @click="changeNav(0)"
      >
        大学介绍
      </div>
      <div
        :style="{ background: tabIndex == 1 ? '#e9efff' : '' }"
        class="schools-nav-left"
        @click="changeNav(1)"
      >
        专业介绍
      </div>
    </div>
    <div v-else class="schools-nav">
      <div
        style="background: #e9efff"
        class="schools-nav-left"
        @click="changeNav(0)"
      >
        招生信息
      </div>
    </div>
    <p v-if="tabIndex == 0" v-html="info.content_one"></p>
    <p v-if="tabIndex == 1 || type == 'zs'" v-html="info.content_two"></p>
  </div>
</template>

<script setup>
import { useRoute } from 'vue-router';
import goBack from '../../components/goBack.vue';
import {
  getSchoolsDetails,
  getAdmissionsDetail
} from '../../api/apiList/homePage.js';

const route = useRoute();
const id = route.query.id;
const type = route.query.type;

console.log('我是进来的', type);
const tabIndex = ref(0);

let info = ref({});
import { onMounted, ref, toRefs } from 'vue';

onMounted(async () => {
  // 获取列表数据
  if (type == 'zs') {
    await getAdmissionsDetail(id).then((res) => {
      const { result } = res;
      info.value = result;
    });
  } else {
    await getSchoolsDetails(id).then((res) => {
      const { result } = res;
      info.value = result;
    });
  }

  // getAdmissionsDetail
});
const changeNav = (index) => {
  tabIndex.value = index;
};
</script>

<style lang="less" scoped>
.schools-nav {
  height: 47px;
  width: 100%;
  display: flex;
  background: #fff;
  border-radius: 30px;
  text-align: center;
  line-height: 47px;
  border: 2px solid #e9efff;

  .schools-nav-left {
    flex: 1;
    font-size: 20px;
    font-family: PingFangSC-Semibold, PingFang SC;
    font-weight: 600;
    color: #333333;
    width: 5.21739rem;
    border-radius: 30px;
  }
}

.schoolDetail {
  background-image: url('../../assets/images/school-detail-bg.jpg');
  background-size: 100% auto;
  background-repeat: no-repeat;
  padding: 76px 20px;
}
</style>
